﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Brain
{
    public class FactoryObject
    {
        public string Name { get; set; }

        public Type Type;

        public bool Editable { get; set; }

        public SetObject Made;

        public void MakeNew(GameScreen mother)
        {
            if (Type != null)
            {
                object o = Activator.CreateInstance(Type);
                if (o is IBaseComponent)
                {
                    mother.AddComponent(o as IBaseComponent);
                }
                if (Made != null)
                {
                    Made(o);
                }
            }
            else
            {
                if (Made != null)
                {
                    Made(mother);
                }
            }
        }

        public override string ToString()
        {
            return Name;
        }
    }
}
